#include "manano_common.h"

#include "mdtx-online/indicator/indicator_type_scale.h"
namespace indi = mdtx::online::indicator;

using rollmad = unary2<indi::rollmad>;
using rolliqr = unary2<indi::rolliqr>;
using rollSn = unary2<indi::rollSn>;
using rollQn = unary2<indi::rollQn>;

void bind_indi_scale(py::module &m)
{
   auto mod = m.def_submodule("scale", "Rolling robust measures of scale");
   {
      auto v = py::class_<rollmad>(mod, "mad")
                   .def(py::init<int>(), py::arg("period"))
                   .def("run", &rollmad::run, py::arg("x"),
                        R"mydoc(
                           Run calculation
                           Args:
                              x (float64) : input data
                           Return:
                              median (float64)
                              MAD (fload64))mydoc")
                   .def("run", &rollmad::run2, py::arg("x"),
                        R"mydoc(
                           Run calculation
                           Args:
                              x (numpy.array) : input data
                           Return:
                              median (numpy.array)
                              MAD (numpy.array))mydoc");
      v.doc() = R"mydoc(
                    Rolling median absolute deviation, adjusted to normal distribution (kappa = 1.4826)
                    Args:
                        period (int) : rolling window period)mydoc";
   }
   {
      auto v = py::class_<rolliqr>(mod, "iqr")
                   .def(py::init<int>(), py::arg("period"))
                   .def("run", &rolliqr::run, py::arg("x"),
                        R"mydoc(Run calculation
                             Args:
                                x (float64) : input data
                             Return:
                                median (float64)
                                IQR (fload64))mydoc")
                   .def("run", &rolliqr::run2, py::arg("x"),
                        R"mydoc(
                           Run calculation
                           Args:
                              x (numpy.array) : input data
                           Return:
                              median (numpy.array)
                              IQR (numpy.array))mydoc");
      v.doc() = R"mydoc(
                    Rolling interquartile range
                    Args:
                        period (int) : rolling window period)mydoc";
   }
   {
      auto v = py::class_<rollSn>(mod, "Sn")
                   .def(py::init<int>(), py::arg("period"))
                   .def("run", &rollSn::run, py::arg("x"),
                        R"mydoc(
                           Run calculation
                           Args:
                              x (float64) : input data
                           Return:
                              median (float64)
                              Sn (fload64))mydoc")
                   .def("run", &rollSn::run2, py::arg("x"),
                        R"mydoc(
                           Run calculation
                           Args:
                              x (numpy.array) : input data
                           Return:
                              median (numpy.array)
                              Sn (numpy.array))mydoc");
      v.doc() = R"mydoc(
                    Rolling Sn, adjusted to normal distribution (kappa = 1.1926)
                    Args:
                        period (int) : rolling window period)mydoc";
   }
   {
      auto v = py::class_<rollQn>(mod, "Qn")
                   .def(py::init<int>(), py::arg("period"))
                   .def("run", &rollQn::run, py::arg("x"),
                        R"mydoc(
                           Run calculation
                           Args:
                              x (float64) : input data
                           Return:
                              median (float64)
                              Qn (fload64))mydoc")
                   .def("run", &rollQn::run2, py::arg("x"),
                        R"mydoc(
                           Run calculation
                           Args:
                              x (numpy.array) : input data
                           Return:
                              median (numpy.array)
                              Qn (numpy.array))mydoc");
      v.doc() = R"mydoc(
                    Rolling Qn, adjusted to normal distribution (kappa = 2.21914)
                    Args:
                        period (int) : rolling window period)mydoc";
   }
}
